package cn.vinann;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

/**
 * Created by vinann on 2017/1/19.
 */
@Service
public class ConsumerService {

    @Autowired
    private RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "addServiceFallback")
    public String add(){
        return restTemplate.getForEntity("http://PRODUCER/add?a=10&b=20",String.class).getBody();
    }

    public String addServiceFallback() {
        return "error";
    }
}
